package day20171221;

import com.sun.javafx.collections.MappingChange;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test04 {
    public static void main(String[] args) {
        Map<String,Integer>map =new HashMap<>();
        //

        BufferedReader reader=null;
        try {
            reader=new BufferedReader(new FileReader("D:\\key.txt"));
            String stuNO=null;

            while ((stuNO=reader.readLine())!=null){
                map.put(stuNO,0);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        //得到某一个文件夹下面所以文件
        File file=new File("D:\\16信本2班Java作业一");

        File[] files=file.listFiles();
        //遍历
        for(File f: files){
            String fileName=f.getName();
            String no=null;
            Matcher matcher= Pattern.compile("信本2班(\\d+)")
                    .matcher(fileName);
            while (matcher.find()){
                no =matcher.group(1);
            }
            map.put(no,1);
        }
        //打印所有value为0，就是没交的同学。
        for (Map.Entry<String,Integer>entry:map.entrySet()){
            if(entry.getValue()==0){
                System.out.println(entry.getKey());

            }
        }
    }
}
